package com.example.ecmftlutil.util.pdf;

import org.ofdrw.converter.export.OFDExporter;
import org.ofdrw.converter.export.PDFExporterIText;
import org.ofdrw.converter.export.PDFExporterPDFBox;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class OfdToPdfUtil {

    public static void main(String[] args) {
        Path ofdPath = Paths.get("D:\\JOB\\odfToPdf\\invoice1722745673123.ofd");
        Path pdfPath = Paths.get("D:\\JOB\\odfToPdf\\daima1.pdf");
        transformationPDFBox(ofdPath, pdfPath);
    }

    private static void transformationPDFBox(Path ofdPath, Path pdfPath) {
        try (OFDExporter exporter = new PDFExporterPDFBox(ofdPath, pdfPath)) {
            exporter.export();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static void transformationIText(Path ofdPath, Path pdfPath) {
        try (OFDExporter exporter = new PDFExporterIText(ofdPath, pdfPath)) {
            exporter.export();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
